<?php


namespace App\Http\Controllers\CmsApi;

use App\Http\Controllers\BaseController;
use App\Http\Model\Hint;
use App\Http\Services\SendAlluserNotifyService;
use App\Lib\Response;
use Illuminate\Http\Request;

class SendAlluserNotifyController extends BaseController
{
    protected $service;//推送服务


    public function __construct()
    {
        $this->service = new SendAlluserNotifyService();
    }

    /**
     * 创建推送消息
     */
    public function insertOrUpnotify(Request $request)
    {
        $request = $request->all();
        //数据处理
        $status = $this->service->insertOrUpnotify($request);
        if ($status) {
            Response::returnResult(Hint::SUCCESS, $status);
        } else {
            Response::returnResult(Hint::ERR_DB_FAIL, $status);
        }
    }
    /**
     * 软删除-推送消息
     */
    public function deletenotify(Request $request)
    {
        $request = $request->all();
        //数据处理
        $status = $this->service->deletenotify($request);
        if ($status) {
            Response::returnResult(Hint::SUCCESS, $status);
        } else {
            Response::returnResult(Hint::ERR_DB_FAIL, $status);
        }
    }
    /**
     * 推送通知
     */
    public function brocatSend(Request $request){
        $param = $request->all();
        //数据处理
        $status = $this->service->brocast($param);
        if ($status) {
            Response::returnResult(Hint::SUCCESS, $status);
        } else {
            Response::returnResult(Hint::ERR_DB_FAIL, $status);
        }
    }
}